import csv
import yaml
from os.path import dirname, join, abspath


class CSVRead:
    def __init__(self):
        with open(join(dirname(str(abspath(__file__))),'init.yml'), 'r', encoding='utf-8') as f:
            init_config= yaml.load(f.read(), Loader=yaml.FullLoader)
        
        self.init_config = init_config
        self.human_init_path = join(dirname(dirname(str(abspath(__file__)))),init_config['human_init_path'])
        
        with open(self.human_init_path, 'r',encoding='utf-8-sig') as csvfile:
            csv_file = csv.reader(csvfile)
            csv_file_list = list(csv_file)
        
        self.csv_file_list = csv_file_list
        self.num_row = len(csv_file_list)
    def csv_read(self, row_index, col_index):
        self.row_index = row_index
        self.col_index = col_index
        self.data = self.csv_file_list[row_index][col_index]
        return self.data